package com.example.langchain4j_spring.service;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import opennlp.tools.util.StringUtil;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * @Author: zjg
 * @Date: 2025/5/13 11:34
 * @Description:
 **/

@Service
public class ToolsService {

    @Tool("某个地区有多少个名字的")
    public Integer changshan_id(@P("地区") String location,@P("姓名") String name){

        //TODO  做业务处理
        System.out.println("category:"+location+"---------"+"name:"+name);
    return 10;
    }

    @Tool("退票")
    public String CannelTicketing(@P("预订号") String orderId,@P("姓名") String name){
        if(StringUtil.isEmpty(orderId) || StringUtil.isEmpty(name)){
            return "预订号或者姓名不能为空";
        }
        //TODO  做业务处理
        System.out.println("订单号:"+orderId+"---------"+"name:"+name);
        return "退票成功";
    }

    @Tool("订票")
    public String addTicketing(@P("姓名") String name,@P("出发地")String location,@P("目的地") String targetLocation,@P("出发日期") String date){
        if (StringUtil.isEmpty(name) || StringUtil.isEmpty(location) || StringUtil.isEmpty(targetLocation) || StringUtil.isEmpty(date)){
            return "请输入完整的信息";
        }
        //TODO  做业务处理
        System.out.println("name:"+name+"---------"+"出发地:"+location+"---------"+"目的地:"+targetLocation+"---------"+"出发日期:"+date);

        return "预订成功，订单号："+ UUID.randomUUID().toString();
    }
}
